package com.example.ly.myapplication;

import android.media.MediaPlayer;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MusicActivity extends AppCompatActivity {
    private MediaPlayer player;
    private String mp3Path ="";
    private boolean isPause = false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_music);
        mp3Path= Environment.getExternalStorageDirectory().getAbsolutePath()+"/mp3/";
        player= new MediaPlayer();
    }
    public void play(View view) throws Exception{
        if (!isPause){
            player.reset();
            player.setDataSource(mp3Path+"meetyou.mp3");
            player.prepare();
        }
        player.start();
        isPause=false;
    }
    public void pause(View view){
        player.pause();
        isPause=true;
    }
}
